import time
import os
from  multiprocessing import Process ,Queue

'''
queue 是线程安全的,先进先出的队列
进程类模式
'''


class process_task(Process):
    def __init__(self,name,q,i):
        super(Process,self).__init__()
        self.name = name
        self.queues=q
        self.i=i
    def run(self) -> None:
        print('进程：{} 正在运行,参数是：{}'.format(self.name,self.i))
        for num in range(self.i):
            self.queues.put(num)

def get_queue(q):
    while True:
        print(q.get())
    pass
if __name__ == '__main__':
    q=Queue(10)

    p1=process_task('task1',q,10)
    p1.start()
    p2=Process(target=get_queue,args=(q,))
    p2.start()
    